package uk.ac.aber.Blockmation;

import java.awt.Color;
import java.awt.GridLayout;

import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JScrollPane;

import uk.ac.aber.Blockmation.ColorsTable.ColorsTable;
/**
 * Creates new dialog window with palette of colors to choose from.
 * <br />
 * Uses ColorsTable as its palette.
 * 
 * @author Aron
 *
 */
public class ColorDialog extends JDialog {
	
    private ColorsTable table;
    ColorDialog( JDialog parent)
    {
        super(parent, true);
 
        table = new ColorsTable(null);
        JPanel panel = new JPanel(new GridLayout(1,0));
        panel.add(table);
        panel.setOpaque(true);

        //Create the scroll pane and add the this to it.
        JScrollPane scrollPane = new JScrollPane(panel);
        //Add the scroll pane to this panel.
        add(scrollPane);
        this.setSize(110, 370);
        this.setVisible(true);
    }
    
	/**
	 * Returns the color selected on the palette.
	 * @return selected color
	 */
    public Color getSelectedColor()
    {
            return table.getSelectedColor();
    }

}
